package com.skyolder.milkbee.tool;

import java.lang.reflect.Field;
import java.time.ZonedDateTime;

import com.skyolder.milkbee.domain.Follow;

public class DomainUtil {
	public static void fill(Object dst,Object ...objects ){
		Field[] fields=dst.getClass().getDeclaredFields();
		for(Field fd:fields){
			fd.setAccessible(true);
			for(Object src:objects){
				try {
					Field srcFd=src.getClass().getDeclaredField(fd.getName());
					srcFd.setAccessible(true);
					fd.set(dst, srcFd.get(src));
					break;
				} catch (NoSuchFieldException e) {
					continue;
				} catch (SecurityException e) {
					continue;
				} catch (IllegalArgumentException e) {
					continue;
				} catch (IllegalAccessException e) {
					continue;
				}
			}
		}
	}
/*	public static void main(String[] args) {
		Follow f1=new Follow();
		Follow f2=new Follow();
		f2.setCreatedAt(ZonedDateTime.now());
		f2.setId(1L);
		DomainUtil.fill(f1, f2);
		System.out.println(f1.getCreatedAt().toString());
	}*/
}
